#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include"button.h"
#include<QLineEdit>


class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

public slots:
    void digitClicked();
    void pointClicked();
    void backSpaceClicked();
    void clear();
    void clearAll();
    void muliplicativeOperatorClicked();
    void additiveOperatorClicked();
    void unaryOperatorClicked();
    void equalClicked();
    void changeClicked();//被点击时进行的操作

private:
    Button* createButton(const QString& text,const char* member);
    bool calucate(double rightOperand,const QString& pendingOperator);
    void abortOperator();//设置button

private:

    double sumSofar;//存储结果
    double factorSoFar;//临时数据

    QString pendingAdditiveOperator;//运算符+-
    QString pendingMultipcativeOperator;//运算符*/

    bool waitingForOperand;//实现一个数字一个运算符交替，而不是接连的几个数字

    QLineEdit* display;
    Button* digitButtons[10];

};
#endif // WIDGET_H
